//
//  JobDetailVC.m
//  MyProject
//
//  Created by jiaming yan on 2018/3/5.
//  Copyright © 2018年 yanjiaming. All rights reserved.
//

#import "JobDetailVC.h"
#import "HXTagsView.h"
#import "HXTagAttribute.h"
#import "AnswersTableViewCell.h"
#import "InterviewExperienceTableViewCell.h"
#import "CompanyVC.h"
@interface JobDetailVC ()<UITableViewDelegate,UITableViewDataSource>
@property (strong, nonatomic) IBOutlet UIView *headView;

@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (strong, nonatomic)  NSMutableArray *arrData;
@property (weak, nonatomic) IBOutlet HXTagsView *tagBackView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *heightOfTags;




/**职位详情*/
@property (weak, nonatomic) IBOutlet HXTagsView *jobTagBackView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *heightOfJobTags;
@property (weak, nonatomic) IBOutlet UILabel *jobDesLabel;
@property (weak, nonatomic) IBOutlet UIButton *jobDesMoreButton;


@property (weak, nonatomic) IBOutlet UILabel *locationLabel;

@end

@implementation JobDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.jobDesMoreButton.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 10);
    self.navigationController.navigationBarHidden = YES;
    _tagBackView.completion = ^(NSArray *selectTags,NSInteger currentIndex) {
        NSLog(@"selectTags:%@ currentIndex:%ld",selectTags, (long)currentIndex);
    };
    _tagBackView.layout.scrollDirection = UICollectionViewScrollDirectionVertical;
    
    HXTagAttribute *model = [[HXTagAttribute alloc]init];
    model.borderWidth  = 0;
    model.borderColor  = kClearColor;
    model.cornerRadius  = 8;
    model.titleSize  = 11;
    model.textColor  = UIColorFromRGB(0x00BCCC);
    model.normalBackgroundColor  = UIColorFromRGB(0xE7F4F6);
    model.selectedBackgroundColor  = UIColorFromRGB(0xE7F4F6);
    model.tagSpace  = 15;
    
    _tagBackView.tagAttribute = model;
    
    [_tagBackView reloadData];
    
    _tagBackView.tags = @[@"员工旅游",@"五险一金",@"领导好相处",@"五险一金",@"领导好相处",@"五险一金",@"领导好相处",@"五险一金",@"领导好相处",@"五险一金",@"领导好相处",@"五险一金",@"领导好相处",@"五险一金",@"领导好相处",@"五险一金",@"领导好相处",@"五险一金",@"领导好相处"];
    
    [_tagBackView reloadData];
    CGFloat height = [HXTagsView getHeightWithTags:self.tagBackView.tags layout:self.tagBackView.layout tagAttribute:self.tagBackView.tagAttribute width:kScreenWidth-30];
    self.heightOfTags.constant = height;
    
    
    
    
    _jobTagBackView.completion = ^(NSArray *selectTags,NSInteger currentIndex) {
        NSLog(@"selectTags:%@ currentIndex:%ld",selectTags, (long)currentIndex);
    };
    _jobTagBackView.layout.scrollDirection = UICollectionViewScrollDirectionVertical;
    _jobTagBackView.tagAttribute = model;
    
   
    
    _jobTagBackView.tags = @[@"员工旅游",@"五险一金",@"领导好相处"];
     [_jobTagBackView reloadData];
    CGFloat jobTagHeight = [HXTagsView getHeightWithTags:_jobTagBackView.tags layout:_jobTagBackView.layout tagAttribute:_jobTagBackView.tagAttribute width:kScreenWidth-30];
    self.heightOfJobTags.constant = jobTagHeight;
    
    [self loadTabbleView];
}
/*
 方法描述:
 加载列表
 
 参数说明:
 <#参数说明#>
 
 返回结果:
 <#返回结果#>
 
 */
-(void)loadTabbleView{
   [self loadHeaderHeight];
    self.tableView.tableHeaderView = self.headView;
    [self.tableView registerNib:[UINib nibWithNibName:@"InterviewExperienceTableViewCell" bundle:nil] forCellReuseIdentifier:@"InterviewExperienceTableViewCell"];
    self.tableView.tableFooterView = [[UIView alloc]init];
    self.tableView.estimatedRowHeight = 184.0f;
    self.tableView.rowHeight = UITableViewAutomaticDimension;
    if (@available(iOS 11.0, *)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        // Fallback on earlier versions
    }
}
#pragma mark ------tableView代理
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 10;self.arrData.count;
}

//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    return 65;
//}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    static NSString *identifier = @"InterviewExperienceTableViewCell";
    InterviewExperienceTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    cell.selectionStyle =  UITableViewCellSelectionStyleNone;
    //    MessageModel *model = self.arrData[indexPath.row];
    //    cell.titleName.text = model.title;
    if (indexPath.row == 5) {
        cell.contentLabel.text = @"中英文都有,中英文混杂的题目,大多数是选择题,笔试完了之后,二面是介绍自己,然后是一些英文问答中英文都有,中英文混杂的题目,大多数是选择题,笔试完了之后,二面是介绍自己,然后是一些英文问答中英文都有,中英文混杂的题目,大多数是选择题,笔试完了之后,二面是介绍自己,然后是一些英文问答中英文都有,中英文混杂的题目,大多数是选择题,笔试完了之后,二面是介绍自己,然后是一些英文问答中英文都有,中英文混杂的题目,大多数是选择题,笔试完了之后,二面是介绍自己,然后是一些英文问答中英文都有,中英文混杂的题目,大多数是选择题,笔试完了之后,二面是介绍自己,然后是一些英文问答中英文都有,中英文混杂的题目,大多数是选择题,笔试完了之后,二面是介绍自己,然后是一些英文问答中英文都有,中英文混杂的题目,大多数是选择题,笔试完了之后,二面是介绍自己,然后是一些英文问答中英文都有,中英文混杂的题目,大多数是选择题,笔试完了之后,二面是介绍自己,然后是一些英文问答";
    }else{
        cell.contentLabel.text = @"中英文都有,中英文混杂的题目,大多数是选择题,笔试完了之后,二面是介绍自己,然后是一些英文问答";
    }
    return cell;
    
}


- (void )tableView:(UITableView *)tableView didSelectRowAtIndexPath:(nonnull NSIndexPath *)indexPath
{
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)backButtonClick:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
- (IBAction)moreJobDesButtonClick:(UIButton *)sender {
    sender.selected = !sender.selected;
    if (sender.selected) {
        self.jobDesLabel.numberOfLines = 0;
    }else{
        self.jobDesLabel.numberOfLines = 3;
    }
    [self loadHeaderHeight];
//    self.tableView.tableHeaderView = self.headView;
}
-(void)loadHeaderHeight{
    [self.locationLabel sizeToFit];
    [self.jobDesLabel sizeToFit];
    CGFloat height = 669+ self.heightOfTags.constant + self.heightOfJobTags.constant + self.jobDesLabel.mj_h + self.locationLabel.mj_h-18.5;
    self.headView.frame = CGRectMake(0, 0, kScreenWidth, height);
    self.tableView.tableHeaderView = self.headView;
    [self.tableView reloadData];
}
- (IBAction)companyDetailClick:(id)sender {
    CompanyVC *vc = [[CompanyVC alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
